package cn.micai.base.concurrent;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 描述：使用原子变量后的计数器
 * <p>
 *
 * @author: 赵新国
 * @date: 2018/5/14 10:57
 */
public class AtomicCounter {

    private AtomicInteger value = new AtomicInteger();

    public int getValue() {
        return value.get();
    }

    public int increment() {
        return value.incrementAndGet();
    }

    public int increment(int i) {
        return value.addAndGet(i);
    }

    public int decrement() {
        return value.decrementAndGet();
    }

    public int decrement(int i) {
        return value.addAndGet(-i);
    }

}
